<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>编辑权限包-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.error{ margin-left: 5px; color: #a94442; }
	.w90{ width: 90px; }
	.w120{ width: 120px; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">权限包 > 编辑权限包</div>
	</div>
	<div id="content">
		<form action="__APP__/System/permissions_group_edit" method="post" id="permission_list_add_validate">
			<input type="hidden" name="id" value="{$id}">
			<input type="hidden" name="action" value="edit">
			<input type="hidden" name="ptype" value="{$type}">
			<div class="form-main">
				<div class="form-title">编辑权限包</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>权限包名称</div>
					<div class="input-item">
						<input type="text" name="permissions_name" value="{$permissions_name}" class="form-control span3 w200" autocomplete="off">
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>分类</div>
					<div class="input-item">
						<select name="type" class="form-control select-add2" autocomplete="off">
							<option value="-10">请选择</option>
							<foreach name="type_list" item="vo">
							<option value="{$vo['name1']}" <if condition="$result_zu['type'] eq $vo['name1']">selected</if>>{$vo['name2']}</option>
							</foreach>
						</select>
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">备注</div>
					<div class="input-item">
						<textarea name="remark" class="form-control w500 h150" autocomplete="off">{$result_zu['remark']}</textarea>
					</div>
				</div>
				<div class="form-sub-title">权限</div>
				<div class="form-item">
					<div class="input-item">
						<foreach name="result" item="vo">
							<if condition="$vo['name_num'] eq 'XM'">
								<div class="group-list-item" style="width:100%">
									<label class="checkbox-inline mr5 w120 first"><input type="checkbox" class="permissions_rule" name="permissions_rule[{$key}]" value="{$vo['name_num']}" <if condition="$vo['num1'] eq $vo['name_num']">checked</if> autocomplete="off">{$vo['name_cn']}</label>
									<span >
										<select name="permissions_select[{$key}]" class="w90 sp_select1 permissions_select permissions_select1" autocomplete="off" data-src="">
										<option value="-10">查看</option>
										<if condition="preg_match('/3/',$vo['s_num'])"><option value="U1" <if condition="$vo['num2'] eq 'U1'">selected</if> snum="3">全部查看</option></if>
										<if condition="preg_match('/2/',$vo['s_num'])"><option value="U2" <if condition="$vo['num2'] eq 'U2'">selected</if> snum="2">中心查看</option></if>
										<if condition="preg_match('/1/',$vo['s_num'])"><option value="U3" <if condition="$vo['num2'] eq 'U3'">selected</if> snum="1">个人查看</option></if>
										</select>
										<label <if condition="$vo['num2'] eq 'U2'">class="checkbox-inline sp_lab1 ml10"<else />class="checkbox-inline hide sp_lab1 ml10"</if>><input type="checkbox" <if condition="preg_match('/130004/',$result_zu['select_id'])">checked</if> class="permissions_rule" name="select_id[]" value="130004" />建设管理</label>
										
										<label <if condition="$vo['num2'] eq 'U2'">class="checkbox-inline sp_lab1"<else />class="checkbox-inline hide sp_lab1"</if>><input type="checkbox" <if condition="preg_match('/130005/',$result_zu['select_id'])">checked</if> class="permissions_rule" name="select_id[]" value="130005" />运营管理</label>
										
										<label <if condition="$vo['num2'] eq 'U2'">class="checkbox-inline sp_lab1 mr20"<else />class="checkbox-inline hide sp_lab1 mr20"</if>><input type="checkbox" <if condition="preg_match('/130011/',$result_zu['select_id'])">checked</if> class="permissions_rule" name="select_id[]" value="130011" />景翼</label>
										<span class="error error_one hide">至少选择一项</span>
										<span class="width hide">&nbsp;</span>
										<select name="permissions_manage[{$key}]" class="w90 sp_select2 permissions_select permissions_select2" autocomplete="off">
										<option value="-10">管理</option>
										<if condition="preg_match('/3/',$vo['g_num'])"><option class="option" value="Q1" <if condition="$vo['num3'] eq 'Q1'">selected</if> qsnum="3">全部管理</option></if>
										<if condition="preg_match('/2/',$vo['g_num'])"><option class="option" value="Q2" <if condition="$vo['num3'] eq 'Q2'">selected</if> qsnum="2">中心管理</option></if>
										<if condition="preg_match('/1/',$vo['g_num'])"><option class="option" value="Q3" <if condition="$vo['num3'] eq 'Q3'">selected</if> qsnum="1">个人管理</option></if>
										<if condition="preg_match('/0/',$vo['g_num'])"><option class="option" value="Q0" <if condition="$vo['num3'] eq 'Q0'">selected</if> qsnum="0">无</option></if>
										</select>
										<label <if condition="$vo['num3'] eq 'Q2'">class="checkbox-inline sp_lab2 ml10"<else />class="checkbox-inline hide sp_lab2 ml10"</if>><input type="checkbox" <if condition="preg_match('/130004/',$result_zu['manage_id'])">checked</if> class="permissions_rule" name="manage_id[]" value="130004" />建设管理</label>
										
										<label <if condition="$vo['num3'] eq 'Q2'">class="checkbox-inline sp_lab2"<else />class="checkbox-inline hide sp_lab2"</if>><input type="checkbox" <if condition="preg_match('/130005/',$result_zu['manage_id'])">checked</if> class="permissions_rule" name="manage_id[]" value="130005" />运营管理</label>
										
										<label <if condition="$vo['num3'] eq 'Q2'">class="checkbox-inline sp_lab2 mr20"<else />class="checkbox-inline hide sp_lab2 mr20"</if>><input type="checkbox" <if condition="preg_match('/130011/',$result_zu['manage_id'])">checked</if> class="permissions_rule" name="manage_id[]" value="130011" />景翼</label>
										<span class="error-item">必填项</span>
										<span class="error error_two hide">至少选择一项</span>
									</span>
								</div>
							<elseif condition="$vo['name_num'] eq 'SW'"/>
								<div class="group-list-item" style="width:100%">
									<label class="checkbox-inline mr5 w120 second"><input type="checkbox" class="permissions_rule" name="permissions_rule[{$key}]" value="{$vo['name_num']}" <if condition="$vo['num1'] eq $vo['name_num']">checked</if> autocomplete="off">{$vo['name_cn']}</label>
									<span >
										<select name="permissions_select[{$key}]" class="w90 sp_select11 permissions_select permissions_select1" autocomplete="off" data-src="">
										<option value="-10">查看</option>
										<if condition="preg_match('/3/',$vo['s_num'])"><option value="U1" <if condition="$vo['num2'] eq 'U1'">selected</if> snum="3">全部查看</option></if>
										<if condition="preg_match('/2/',$vo['s_num'])"><option value="U2" <if condition="$vo['num2'] eq 'U2'">selected</if> snum="2">中心查看</option></if>
										<if condition="preg_match('/1/',$vo['s_num'])"><option value="U3" <if condition="$vo['num2'] eq 'U3'">selected</if> snum="1">个人查看</option></if>
										</select>
										<label <if condition="$vo['num2'] eq 'U2'">class="checkbox-inline sp_lab11 ml10"<else />class="checkbox-inline hide sp_lab11 ml10"</if>><input type="checkbox" <if condition="preg_match('/130003/',$result_zu['sw_select_id'])">checked</if> class="permissions_rule" name="sw_select_id[]" value="130003" />拓展中心</label>
										<label <if condition="$vo['num2'] eq 'U2'">class="checkbox-inline sp_lab11"<else />class="checkbox-inline hide sp_lab11"</if>><input type="checkbox" <if condition="preg_match('/130004/',$result_zu['sw_select_id'])">checked</if> class="permissions_rule" name="sw_select_id[]" value="130004" />建设管理</label>
										<label <if condition="$vo['num2'] eq 'U2'">class="checkbox-inline sp_lab11 mr20"<else />class="checkbox-inline hide sp_lab11 mr20"</if>><input type="checkbox" <if condition="preg_match('/130011/',$result_zu['sw_select_id'])">checked</if> class="permissions_rule" name="sw_select_id[]" value="130011" />景翼</label>
										<span class="error error_onet hide">至少选择一项</span>
										<span class="width1 hide">&nbsp;</span>
										<select name="permissions_manage[{$key}]" class="w90 sp_select22 permissions_select permissions_select2" autocomplete="off">
										<option value="-10">管理</option>
										<if condition="preg_match('/3/',$vo['g_num'])"><option class="option" value="Q1" <if condition="$vo['num3'] eq 'Q1'">selected</if> qsnum="3">全部管理</option></if>
										<if condition="preg_match('/2/',$vo['g_num'])"><option class="option" value="Q2" <if condition="$vo['num3'] eq 'Q2'">selected</if> qsnum="2">中心管理</option></if>
										<if condition="preg_match('/1/',$vo['g_num'])"><option class="option" value="Q3" <if condition="$vo['num3'] eq 'Q3'">selected</if> qsnum="1">个人管理</option></if>
										<if condition="preg_match('/0/',$vo['g_num'])"><option class="option" value="Q0" <if condition="$vo['num3'] eq 'Q0'">selected</if> qsnum="0">无</option></if>
										</select>
										<label <if condition="$vo['num3'] eq 'Q2'">class="checkbox-inline sp_lab22 ml10"<else />class="checkbox-inline hide sp_lab22 ml10"</if>><input type="checkbox" <if condition="preg_match('/130003/',$result_zu['sw_manage_id'])">checked</if> class="permissions_rule" name="sw_manage_id[]" value="130003" />拓展中心</label>
										<label <if condition="$vo['num3'] eq 'Q2'">class="checkbox-inline sp_lab22"<else />class="checkbox-inline hide sp_lab22"</if>><input type="checkbox" <if condition="preg_match('/130004/',$result_zu['sw_manage_id'])">checked</if> class="permissions_rule" name="sw_manage_id[]" value="130004" />建设管理</label>
										<label <if condition="$vo['num3'] eq 'Q2'">class="checkbox-inline sp_lab22 mr20"<else />class="checkbox-inline hide sp_lab22 mr20"</if>><input type="checkbox" <if condition="preg_match('/130011/',$result_zu['sw_manage_id'])">checked</if> class="permissions_rule" name="sw_manage_id[]" value="130011" />景翼</label>
										<span class="error-item">必填项</span>
										<span class="error error_twot hide">至少选择一项</span>
									</span>
								</div>
							<else />
								<div class="group-list-item">
									<label class="checkbox-inline mr5 w120"><input type="checkbox" class="permissions_rule" name="permissions_rule[{$key}]" value="{$vo['name_num']}" <if condition="$vo['num1'] eq $vo['name_num']">checked</if> autocomplete="off">{$vo['name_cn']}</label>
									<span >
										<select name="permissions_select[{$key}]" class="w90 permissions_select permissions_select1" autocomplete="off" data-src="">
										<option value="-10">查看</option>
										<if condition="preg_match('/3/',$vo['s_num'])"><option value="U1" <if condition="$vo['num2'] eq 'U1'">selected</if> snum="3">全部查看</option></if>
										<if condition="preg_match('/2/',$vo['s_num'])"><option value="U2" <if condition="$vo['num2'] eq 'U2'">selected</if> snum="2">中心查看</option></if>
										<if condition="preg_match('/1/',$vo['s_num'])"><option value="U3" <if condition="$vo['num2'] eq 'U3'">selected</if> snum="1">个人查看</option></if>
										</select>
										<select name="permissions_manage[{$key}]" class="w90 permissions_select permissions_select2" autocomplete="off">
										<option value="-10">管理</option>
										<if condition="preg_match('/3/',$vo['g_num'])"><option class="option" value="Q1" <if condition="$vo['num3'] eq 'Q1'">selected</if> qsnum="3">全部管理</option></if>
										<if condition="preg_match('/2/',$vo['g_num'])"><option class="option" value="Q2" <if condition="$vo['num3'] eq 'Q2'">selected</if> <if condition="$vo['name_num'] eq KX">qsnum="3"<else/>qsnum="2"</if>><if condition="$vo['name_num'] eq KX">开票管理<else/>中心管理</if></option></if>
										<if condition="preg_match('/1/',$vo['g_num'])"><option class="option" value="Q3" <if condition="$vo['num3'] eq 'Q3'">selected</if> <if condition="$vo['name_num'] eq KX">qsnum="3"<else/>qsnum="1"</if>><if condition="$vo['name_num'] eq KX">付款管理<else/>个人管理</if></option></if>
										<if condition="preg_match('/6/',$vo['g_num'])"><option class="option" value="Q6" <if condition="$vo['num3'] eq 'Q6'">selected</if> qsnum="6">录入管理</option></if>
										<if condition="preg_match('/7/',$vo['g_num'])"><option class="option" value="Q7" <if condition="$vo['num3'] eq 'Q7'">selected</if> qsnum="7">修改管理</option></if>
										<if condition="preg_match('/8/',$vo['g_num'])"><option class="option" value="Q8" <if condition="$vo['num3'] eq 'Q8'">selected</if> qsnum="8">批复管理</option></if>
										<if condition="preg_match('/9/',$vo['g_num'])"><option class="option" value="Q9" <if condition="$vo['num3'] eq 'Q9'">selected</if> qsnum="9">批复管理</option></if>
										<if condition="preg_match('/0/',$vo['g_num'])"><option class="option" value="Q0" <if condition="$vo['num3'] eq 'Q0'">selected</if> qsnum="0">无</option></if>
										</select>
										<span class="error-item">必填项</span>
									</span>
								</div>
							</if>
						</foreach>
					</div>
				</div>
			</div>
			<div class="form-btn-item"><button class="btn sub" type="submit">提交</button><button class="btn btn-default goback" type="button">返回</button></div>
		</form>	
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$(".sp_select1").change(function(){
		var snum = $(this).find('option:checked').attr('snum');
		$('.sp_lab2').hide();
		$(".sp_lab1 input,.sp_lab2 input").attr("checked",false);
		if(snum==2){
			$('.sp_lab1').show();
			$('.width').show();
		}else{
			$('.sp_lab1').hide();
			$('.width').hide();
		}
	})
	$(".sp_select2").change(function(){
		var qsnum = $(this).find('option:checked').attr('qsnum');
		$(".sp_lab2 input").attr("checked",false);
		if(qsnum==2){
			$('.sp_lab2').show();
		}else{
			$('.sp_lab2').hide();
		}
	})
	$(".sp_select11").change(function(){
		var snum = $(this).find('option:checked').attr('snum');
		$('.sp_lab22').hide();
		$(".sp_lab11 input,.sp_lab22 input").attr("checked",false);
		if(snum==2){
			$('.sp_lab11').show();
			$('.width1').show();
		}else{
			$('.sp_lab11').hide();
			$('.width1').hide();
		}
	})
	$(".sp_select22").change(function(){
		var qsnum = $(this).find('option:checked').attr('qsnum');
		$(".sp_lab22 input").attr("checked",false);
		if(qsnum==2){
			$('.sp_lab22').show();
		}else{
			$('.sp_lab22').hide();
		}
	})
	$("[name='permissions_rule[]']").on('click',function(){
		var span = $(this).parent().next("span");
		if($(this).prop("checked")){
			span.show();
		}else{
			span.hide().find("select").val(-10).select2().end().find(".error-item").hide();
		}
	});
	//限制
	$('.group-list-item').each(function(i){
		var datas = $('.permissions_select2').eq(i).html();
		$('.permissions_select1').eq(i).attr('data-src',datas);
	})
	$('.permissions_select').change(function(){
		var _this = $(this),
			snum = _this.find("option:selected").attr("snum"),
			srcs = _this.attr('data-src');
		_this.nextAll('select').html(srcs).select2();
		var aOption = _this.nextAll('select').find('.option');
		for(let i = 0; i < aOption.length; i++){
			if(parseInt(snum) < parseInt(aOption.eq(i).attr('qsnum'))){
				aOption.eq(i).remove();
			}
		}
	})
	$('.sp_lab1').click(function(){
		$('.error_one').hide();
	})
	$('.sp_lab11').click(function(){
		$('.error_one').hide();
	})
	$('.permissions_select1').change(function(){
		$('.error_one').hide();
	})
	$('.sp_lab2').click(function(){
		$('.error_two').hide();
	})
	$('.sp_lab22').click(function(){
		$('.error_two').hide();
	})
	$('.permissions_select2').change(function(){
		$('.error_two').hide();
	})
	//提交
	$(".sub").click(function(){
		var flag = false;
		$("[name='permissions_name']").each(function(){
			var $val = $(this).val();
			if($val=="" || /^\s+$/.test($val)){
				$(this).next(".error-item").show();
				flag = true;
			}
		});
		$("[name='type']").each(function(){
			var val = $(this).val();
			if(val == -10){
				$(this).nextAll(".error-item").show();
				flag = true;
			}
		})
		if($('.first input:checked').length>0){
			if($('.sp_lab1').is(':hidden')){

			}else{
				if($('.sp_lab1 input:checked').length==0){
					$('.error_one').show();
					flag = true;
				}
			}
			if($('.sp_lab2').is(':hidden')){

			}else{
				if($('.sp_lab2 input:checked').length==0){
					$('.error_two').show();
					flag = true;
				}
			}
		}
		if($('.second input:checked').length>0){
			if($('.sp_lab11').is(':hidden')){

			}else{
				if($('.sp_lab11 input:checked').length==0){
					$('.error_onet').show();
					flag = true;
				}
			}
			if($('.sp_lab22').is(':hidden')){

			}else{
				if($('.sp_lab22 input:checked').length==0){
					$('.error_twot').show();
					flag = true;
				}
			}
		}
		if($(".permissions_rule:checked").length==0){
			defeated_alert('请至少勾选一项权限');
			flag = true;
		}
		$(".group-list-item").each(function(i){
			_this = $(this);
			if($(".permissions_rule:checked").eq(i).parent().siblings('span').find('.permissions_select1').val()==-10){
				$(".permissions_rule:checked").eq(i).parent().siblings('span').find(".error-item").show();
				flag = true;
			}
			if($(".permissions_rule:checked").eq(i).parent().siblings('span').find('.permissions_select2').val()==-10){
				$(".permissions_rule:checked").eq(i).parent().siblings('span').find(".error-item").show();
				flag = true;
			}
		});
		if(flag){
			return false;
		}
	});

	//取消错误提示
	$("[name='permissions_name']").focus(function(){
		$(this).next(".error-item").hide();
	});
	$(".permissions_select,[name='type']").on("change",function(){
		$(this).nextAll(".error-item").hide();
	});
});
</script>
</body>
</html>
	
